package mlz.c_newDateClass;

import java.time.Clock;
import java.time.ZoneId;
import java.time.ZonedDateTime;

//ZoneId: 时区
public class ZoneIdDemo04 {
    public static void main(String[] args) {
        //获取系统默认的时区
        ZoneId zoneId = ZoneId.systemDefault();
        System.out.println(zoneId);//Asia/Shanghai
        String id = zoneId.getId();
        System.out.println(id);//Asia/Shanghai

        //获取Java支持的全部时区的id
        System.out.println(ZoneId.getAvailableZoneIds());

        //把某个时区的id封装成ZoneId对象
        ZoneId zoneId1 = ZoneId.of("Asia/Shanghai");


        //带时区的时间
        ZonedDateTime time = ZonedDateTime.now(zoneId1);
        System.out.println(time);//2024-10-07T13:03:29.117120200+08:00[Asia/Shanghai]

        //世界标准时间
        ZonedDateTime now = ZonedDateTime.now(Clock.systemUTC());
        System.out.println(now);//2024-10-07T05:05:25.143808900Z


    }
}
